﻿using Inovout.Cloud.Client.Storage.Data;
using System;
using Xunit;

namespace Inovout.Cloud.Client.Storage.Tests
{
    public class BucketTest : StorageTest
    {
        [Fact(DisplayName = "InsertBucket")]
        public void Insert()
        {
            StorageService storageService = new StorageService(new Inovout.Cloud.Client.Services.BaseClientService.Initializer
            {
                ApiKey = CloudApplicationUser.Application.Name
            });
            Bucket newBucket = storageService.Buckets.Insert(new Bucket
            {
                Name = "mybucket" + DateTime.Now.Ticks.ToString()
                //Location = "US",
                //StorageClass = "DURABLE_REDUCED_AVAILABILITY"
            }, CloudProject.Name).Execute();
        }
        [Fact(DisplayName = "ListBucket")]
        public void List()
        {
            StorageService storageService = new StorageService(new Inovout.Cloud.Client.Services.BaseClientService.Initializer
            {
                ApiKey = CloudApplicationUser.Application.Name
            });

            Bucket newBucket = storageService.Buckets.Insert(new Bucket
            {
                Name = "mybucket" + DateTime.Now.Ticks.ToString()
                //Location = "US",
                //StorageClass = "DURABLE_REDUCED_AVAILABILITY"
            }, CloudProject.Name).Execute();
            var buckets = storageService.Buckets.List(CloudProject.Name).Execute();
        }

        [Fact(DisplayName = "DeleteBucket")]
        public void Delete()
        {
            StorageService storageService = new StorageService(new Inovout.Cloud.Client.Services.BaseClientService.Initializer
            {
                ApiKey = CloudApplicationUser.Application.Name
            });

            Bucket newBucket = storageService.Buckets.Insert(new Bucket
            {
                Name = "mybucket" + DateTime.Now.Ticks.ToString()
            }, CloudProject.Name).Execute();
            storageService.Buckets.Delete(newBucket.Name).Execute();
        }

    }
}
